package {
	import testPureMvc.ApplicationFacade;
	import testPureMvc.components.MainScreen;

	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;

	/**
	 * @author Johannes Scherg
	 */
	
	[SWF(backgroundColor="0xFFFFFF", frameRate="25", width="698", height="318")]
	
	
	public class Application extends Sprite 
	{
		
		public static const NAME : String = "Application";

		public static const NAME_MAIN_SCREEN : String = "mainScreen";
		public var mainScreen : MainScreen = new MainScreen();
		
		private var _facade : ApplicationFacade;
		
		// Constructor
		public function Application() 
		{
			trace("Application init ...");
			_facade = ApplicationFacade.getInstance(NAME);
			
			addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
		
		}

		public function addedToStageHandler(e : Event) : void
		{
			// setup stage properties
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			Globals.STAGE = stage;
			Globals.STAGE_WIDTH = 698;
			Globals.STAGE_HEIGHT = 318;
			// start app
			_facade.startApp(this);
		}

		public function addObj(obj : String) : void
		{
			trace("add Obj: " + obj);
			addChild(this[obj]);
		}




	}
}
